<%
# Code Review plugin for Redmine
# Copyright (C) 2009  Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-%>

<div id="code_review_list">
<h2>
  <%=h l(:code_reviews) %>
</h2>

<% if @all_review_count > 0 %>
<p>
<% form_tag 'show_option', :controller => 'code_review', :action=>'index', :id => @project do %>
    <%= check_box_tag 'show_closed', 'true', @show_closed %> <%=h l(:label_show_closed_reviews) %>
<% end %>
<%= observe_field 'show_closed', :with => 'show_closed', :update => 'content' %>
</p>
<% end %>

<% if @reviews == nil or @reviews.length == 0 %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% else %>


<table class="list">
  <thead>
    <tr>
      <th>
        <%= sort_header_tag("#{Issue.table_name}.id", :caption => '#') %>
      </th>
      <th>
        <%= sort_header_tag "#{Issue.table_name}.status_id", :caption => l(:field_status)%>
      </th>
      <th>
        <%= sort_header_tag 'path', :caption => l(:label_code_path)%>
      </th>
      <th>
        <%=h l(:label_code_line)%>
      </th>
      <th>
        <%= sort_header_tag "#{Changeset.table_name}.revision", :caption => l(:label_revision)%>
      </th>
      <th>
        <%= sort_header_tag "#{Changeset.table_name}.committer", :caption => l(:label_code_author)%>
      </th>
      <th>
        <%= sort_header_tag 'user_id', :caption => l(:label_code_reviewer)%>
      </th>
      <th>
        <%= sort_header_tag 'updated_at', :caption => l(:label_date) %>
      </th>
    </tr>
  </thead>
  <tbody>
    <% for review in @reviews %>
      <tr class="<%= cycle 'odd', 'even' %>">
        <td colspan="2"><%=  review.issue.id %></td>
                
        <td colspan="2" class="status">
          <%=h  review.issue.status %>
        </td>
        <td colspan="2" class="path">
          <%
            codepath = review.path
            if (review.path.length > 55)
              codepath = review.path[0, 15] + '...' + review.path[review.path.length - 35, 35]
            end
          -%>
<%= link_to(codepath, {:controller => 'code_review', :action => 'show', :id => @project, :review_id => review.id}, :title => review.path) -%>
      　</td>
        <td><%=h review.line %></td>
        <td colspan="2"><%=h review.revision %></td>
        <td colspan="2"><%=h review.committer %></td>
        <td colspan="2"><%=h review.user.name %></td>
        <td colspan="2"><%=h format_time(review.created_at) %></td>
      </tr>
    <% end %>
  </tbody>
</table>
<p class="pagination"><%= pagination_links_full @review_pages, @review_count %></p>

<% end %>

<% content_for :header_tags do %>
  <%= stylesheet_link_tag "code_review.css", :plugin => "redmine_code_review", :media => "screen" %>
<% end %>
</div>